<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>版本记录</title>
    <link rel="shortcut icon" type="image/x-icon" href="../../favicon.ico" />
    <link rel="stylesheet" href="../../component/pear/css/pear.css">
    <script src="../../js/myUtils.js"></script>
</head>

<body class="pear-container">
    <div class="layui-card">
        <div class="layui-card-body">
            <table class="layui-hide" id="excel-history-table"></table>
        </div>
    </div>

    <script type="text/html" id="operationTpl">
        {{#  if(d.operation === 2){ }}
        <span style="color: #ff4927;">删除</span>
        {{#  } else if((d.operation === 1)) { }}
        <span style="color: #0084ff;">修改</span>
        {{#  } else if((d.operation === 0)) { }}
        <span style="color: #2ebd59;">新增</span>
        {{#  } }}
    </script>

    <script type="text/html" id="involvedRegionTpl">
        {{# layui.each(d.involvedRegion, function(index, item){ }}
            <div class="layui-input-inline">
                {{#  if(item.province != null){ }}
                {{item.province}}{{item.city}}{{item.area}}
                {{#  } }}
            </div>
        {{# }); }}
    </script>

    <script type="text/html" id="blackNameTpl">
        {{# layui.each(d.reporteders, function(index, item){ }}
        <div class="layui-input-inline">{{item.name}}</div>
        {{# }); }}
    </script>

    <script type="text/html" id="blackCardIdTpl">
        {{# layui.each(d.reporteders, function(index, item){ }}
        {{#  if(item.blackCardId != ''){ }}
        <div class="layui-input-inline">{{item.blackCardId}}</div>
        {{#  } }}
        {{# }); }}
    </script>

    <script type="text/html" id="caseTypeTpl">
        {{# layui.each(d.reporteders, function(index, item){ }}
        {{#  if(item.caseType != ''){ }}
        <div class="layui-input-inline">{{item.caseType}}&nbsp;</div>
        {{#  } }}
        {{# }); }}
    </script>

    <script type="text/html" id="blackDepartmentTpl">
        {{# layui.each(d.reporteders, function(index, item){ }}
        {{#  if(item.blackDepartment == ''){ }}
        <div class="layui-input-inline">无单位</div>
        {{#  } else { }}
        <div class="layui-input-inline">{{item.blackDepartment}}</div>
        {{#  } }}
        {{# }); }}
    </script>

    <script type="text/html" id="involvedUnitTpl">
        {{# layui.each(d.involvedUnit, function(index, item){ }}
            <div class="layui-input-inline">{{item}}</div>
        {{# }); }}
    </script>

    <script type="text/html" id="sendDepartmentTpl">
        {{#  if(d.sendDepartment != ''){ }}
            {{#  if(d.sendDepartment.value != -1){ }}
                {{#  if(d.sendDepartment.value != 0){ }}
                <div class="layui-input-inline">{{d.sendDepartment.name}}</div>
                {{#  } else { }}
                <div class="layui-input-inline">{{d.sendDepartmentMemo}}</div>
                {{#  } }}
            {{#  } }}
        {{#  } }}
    </script>

    <script type="text/html" id="reportFromTpl">
        {{#  if(d.reportFrom.value != -1){ }}
        <div class="layui-input-inline">{{d.reportFrom.name}}</div>
        {{#  } }}
    </script>

    <script type="text/html" id="levelTpl">
        {{#  if(d.level.value != -1){ }}
        <div class="layui-input-inline">{{d.level.name}}</div>
        {{#  } }}
    </script>

    <script type="text/html" id="conclusionTpl">
        {{#  if(d.conclusion.value != -1){ }}
        <div class="layui-input-inline">{{d.conclusion.name}}</div>
        {{#  } }}
    </script>

    <script type="text/html" id="fourShapesTpl">
        {{#  if(d.fourShapes.value != -1){ }}
        <div class="layui-input-inline">{{d.fourShapes.name}}</div>
        {{#  } }}
    </script>

    <script type="text/html" id="processResultTpl">
        {{#  if(d.processResult.value != -1){ }}
        <div class="layui-input-inline">{{d.processResult.name}}</div>
        {{#  } }}
    </script>

    <script type="text/html" id="issueTypeTpl">
        {{# layui.each(d.issueType, function(index, item){ }}
        {{#  if(d.issueType.length != 0){ }}
        <div class="layui-input-inline">{{item}}</div>
        {{#  } }}
        {{# }); }}
    </script>

    <script type="text/html" id="isSendTpl">
        {{#  if(d.isSend === '否'){ }}
        <span style="color: #ff4927;">{{ d.isSend }}</span>
        {{#  } else { }}
        <span style="color: #0084ff;">{{ d.isSend }}</span>
        {{#  } }}
    </script>

    <script type="text/html" id="isRepeatTpl">
        {{#  if(d.isRepeat === '不重复'){ }}
        {{ d.isRepeat }}
        {{#  } else { }}
        <span style="color: #ff4927;">{{ d.isRepeat }}</span>
        {{#  } }}
    </script>

    <script type="text/html" id="progressTpl">
        {{#  if(d.progress === '查结'){ }}
        <span style="color: #2ebd59;">{{ d.progress }}</span>
        {{#  } else if((d.progress === '正在核查')) { }}
        <span style="color: #0084ff;">{{ d.progress }}</span>
        {{#  } else { }}
        <span style="color: #F6AD55;">{{ d.progress }}</span>
        {{#  } }}
    </script>

    <script src="../../js/jquery.js"></script>
    <script src="../../component/layui/layui.js"></script>
    <script src="../../component/pear/pear.js"></script>

    <script>
        var locationParams = myUtils.GetRequest()
        // console.log("版本记录页面locationParams: ", locationParams)
        layui.use(['table', 'form', 'Api'], function () {
            var $ = layui.$;
            var form = layui.form,
                table = layui.table,
                Api = layui.Api,
                upload = layui.upload

            var reportId = locationParams.id
            var url = Api.log
            var param = {}
            if (reportId != undefined) {
                param = {
                    reportId: reportId
                }
            }

            function uniformHistroy(data) {
                var historyData = []
                for (let i = 0; i < data.length; i++) {
                    var item = JSON.parse(data[i].newValue)
                    item['operation'] = data[i].operation
                    item['enterer'] = data[i].enterer
                    item['createTime'] = data[i].createTime
                    historyData.push(item)
                }
                return historyData
            }
            var pageChoose = [10, 100]
            var myTable = table.render({
                elem: '#excel-history-table',
                id: 'excel-history-table',
                autoSort: true,
                url: url,
                where: param,
                headers: {
                    'token': localStorage.token
                },
                parseData: function (res) { //res 即为原始返回的数据
                    if (res.errno != 0) {
                        layer.alert(res.errmsg, { icon: 2 }, function (index) {
                            layer.close(index);
                        });
                    }
                    var data = res.data.list,
                        data = uniformHistroy(data)
                        data = myUtils.parseData(data)
                    pageChoose.pop()
                    pageChoose.push(res.data.total)
                    return {
                        "code": res.errno, //解析接口状态
                        "msg": res.errmsg, //解析提示文本
                        "count": res.data.total, //解析数据长度
                        "data": data //解析数据列表
                    };
                },
                request: {
                    pageName: 'page_index' //页码的参数名称，默认：page
                    ,
                    limitName: 'page_size' //每页数据量的参数名，默认：limit
                },
                title: "历史记录表",
                page: {
                    limit: 10,
                    limits: pageChoose,
                },
                loading: false,
                // skin: 'line',
                toolbar: '#toolbar',
                defaultToolbar: ['filter', 'exports'],  /* 调整数据表格右侧工具栏 */
                smartReloadModel: true,
                cols: [
                    [   // 一级表头
                        { sort: false, align: 'center', hide: false, type: 'numbers', fixed: 'left', title: '序号' },
                        { sort: true, align: 'center', hide: false, minWidth: 110, field: 'operation', title: '操作类型', templet: '#operationTpl' },
                        { sort: true, align: 'center', hide: false, minWidth: 160, field: 'createTime', title: '操作时间', },
                        { sort: true, align: 'center', hide: false, minWidth: 110, field: 'enterer', title: '操作人', },

                        { sort: true, align: 'center', hide: false, minWidth: 170, field: 'no', title: '受理编号' },
                        { sort: true, align: 'center', hide: false, minWidth: 150, field: 'mailNo', title: '来电来信线索编号', },
                        { sort: true, align: 'center', hide: false, minWidth: 150, field: 'reportType', title: '线索来源' },
                        { sort: true, align: 'center', hide: false, minWidth: 150, field: 'reportFrom', title: '一手来源单位' },
                        { sort: true, align: 'center', hide: false, minWidth: 160, field: 'moreLetter', title: '还要来信反映' },
                        { sort: false, align: 'center', hide: false, minWidth: 200, field: 'involvedRegion', title: '涉及区域', templet: '#involvedRegionTpl' },
                        { sort: false, align: 'center', hide: false, minWidth: 120, field: 'name', title: '举报人姓名', templet: '<span>{{d.reporter.name}}</span>' },
                        { sort: false, align: 'center', hide: false, minWidth: 200, field: 'cardId', title: '身份证号', templet: '<span>{{d.reporter.cardId}}</span>' },
                        { sort: false, align: 'center', hide: false, minWidth: 120, field: 'phone', title: '联系方式', templet: '<span>{{d.reporter.phone}}</span>' },
                        { sort: false, align: 'center', hide: false, minWidth: 120, field: 'location', title: '住所地', templet: '<span>{{d.reporter.location}}</span>' },

                        { sort: false, align: 'center', hide: false, minWidth: 160, field: 'reporteders', title: '被举报人姓名', templet: '#blackNameTpl' },
                        { sort: false, align: 'center', hide: false, minWidth: 160, field: 'reporteders', title: '被举报人单位', templet: '#blackDepartmentTpl' },
                        { sort: true, align: 'center', hide: false, minWidth: 200, field: 'blackCardId', title: '被举报人身份证', templet: '#blackCardIdTpl' },
                        { sort: true, align: 'center', hide: false, minWidth: 120, field: 'question', title: '主要问题', },
                        { sort: true, align: 'center', hide: false, minWidth: 120, field: 'caseType', title: '线索类别', templet: '#caseTypeTpl'},

                        { sort: false, align: 'center', hide: false, minWidth: 220, field: 'issueType', title: '顽瘴痼疾类别', templet: '#issueTypeTpl' },
                        { sort: false, align: 'center', hide: false, minWidth: 160, field: 'involvedUnit', title: '涉及单位', templet: '#involvedUnitTpl' },
                        { sort: true, align: 'center', hide: false, minWidth: 130, field: 'isVolunteered', title: '主动说明情况' },
                        { sort: true, align: 'center', hide: false, minWidth: 110, field: 'isSweepBlack', title: '扫黑除恶' },
                        { sort: false, align: 'center', hide: false, minWidth: 150, field: 'completeDataMemo', title: '数据完善备注', },

                        { sort: true, align: 'center', hide: false, minWidth: 110, field: 'isSend', title: '是否移送', templet: '#isSendTpl' },
                        { sort: true, align: 'center', hide: false, minWidth: 130, field: 'reportState', title: '移送状态' },
                        { sort: true, align: 'center', hide: false, minWidth: 110, field: 'sendDepartment', title: '移送单位' },
                        { sort: true, align: 'center', hide: false, minWidth: 110, field: 'sendTime', title: '移交时间', },
                        { sort: true, align: 'center', hide: false, minWidth: 180, field: 'sendToId', title: '移送编号' },
                        { sort: true, align: 'center', hide: false, minWidth: 110, field: 'feedbackTimeLimit', title: '反馈时限', },
                        { sort: true, align: 'center', hide: false, minWidth: 110, field: 'feedbackTime', title: '反馈时间', },
                        { sort: true, align: 'center', hide: true, minWidth: 110, field: 'doneTimeLimit', title: '查结时限', },

                        { sort: true, align: 'center', hide: false, minWidth: 110, field: 'level', title: '核查等级' },
                        { sort: true, align: 'center', hide: false, minWidth: 110, field: 'progress', title: '核查进展', templet: '#progressTpl' },
                        { sort: true, align: 'center', hide: false, minWidth: 110, field: 'conclusion', title: '核查结论' },
                        { sort: true, align: 'center', hide: false, minWidth: 110, field: 'fourShapes', title: '四种形态' },
                        { sort: true, align: 'center', hide: false, minWidth: 110, field: 'processResult', title: '处理结果' },
                        { sort: false, align: 'center', hide: false, minWidth: 150, field: 'feedbackMemo', title: '核查反馈备注', },

                        { sort: true, align: 'center', hide: false, minWidth: 110, field: 'isRepeat', title: '是否重复', templet: '#isRepeatTpl' },
                    ]
                ],
                // size: 'lg',
                done: function (res, curr, count) {
                    // console.log("res:", res)
                }
            });


        });
    </script>
</body>

</html>